import java.util.Scanner;

public class Test {
    public static void main(String[] ages) {
        Scanner scan = new Scanner(System.in);
        int a = 0;
        int code = 123;
        for (int i = 0; i < 3; i++) {
            System.out.print("请输入密码：");
            int n = scan.nextInt();
            if(n == code) {
                System.out.println("密码正确，登录成功！");
                a=1;
                break;
            }
            System.out.println("密码错误，请重新输入");
        }
        if(a == 0)
            System.out.println("3次密码错误，登录失败！");
    }

}
